from operator import attrgetter

class NewsCriteria(object):
    """Represents a particular subset of the documents in a
    repository, for the purpose of generating a news feed for that
    subset.

    :param basefile: A slug-like basic text label for this subset.
    :param feedtitle: ...
    :param selector: callable
    :param key: callable
    """
    def __init__(self, basefile, feedtitle, selector=None, key=None):
        self.basefile = basefile
        self.feedtitle = feedtitle
        if not selector:
            self.selector = lambda x: True
        else:
            assert callable(selector)
            self.selector = selector
        if not key:
            self.key = attrgetter('updated') # or lambda x: x.updated
        else:
            assert callable(key)
            self.key = key
        self.entries = []
